'use strict';
//
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	//获取数据库的对象
	const db = uniCloud.database();
	//获取表的对象
	const tb = db.collection("resume");
	//一个给对象设置值的对象 用于修改
	const dbCmd =db.command;
	//根据类型进行操作
	switch (event.type) {
		//将简历附件添加到简历表
		case 'addResume': {
				let {user_id,url,file_name,time}=event;
				let data = await tb.add({
					user_id:user_id,
					url:url,
					file_name:file_name,
					time:time
				})
				return {state:200,data:data};
		};
		//根据用户id查找该用户的所有简历附件
		case "showAllResume": {
			let{user_id} =event;
			//查找
			let data=await tb.where({
				user_id:user_id
			}).get()
			return {state:200,data:data};
		};
	}

};
